package com.tgy.赫夫曼树.赫夫曼编码;

import java.util.HashMap;
import java.util.Optional;

/***
 * @ClassName: Test2
 * @Description:
 * @Auther: tanggy3
 * @Date: 11:21 2023/2/22
 * @version : V1.0
 */
public class Test2 {
    public static void main(String[] args) {
        HashMap<String, String> map = new HashMap<>();
        map.put("a","A");
        map.put("b",null);

        //String orDefault = Optional.ofNullable(map.get("b")).toString();
        String orDefault = Optional.ofNullable(map.get("b")).orElse("D").toString();
        String b = Optional.ofNullable(map.get("b")).orElseGet(() -> "这是使用了orElseGet");
        System.out.println(b);
    }
}

